﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DevLib.SuperTool;
using DevLib.FileTool;
using System.IO;

/** 
 ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
 * Description: 
 * Author: Heller (HellerSong@outlook.com)
 * CreationTime: 3/24/2015 10:53:04 PM
 ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** 
 **/
namespace UnitTest.TestFileTool
{
	[TestClass]
	public class TestDirOM
	{
		[TestMethod]
		public void test_get_parent_dir()
		{
			string path = DevGlobal.PATH_SOLUTION;
			Console.WriteLine(path);
			Console.WriteLine(DirOM.GetParrentDirectory(path));
			Console.WriteLine(DirOM.GetParrentDirectory(path, 2));
		}

		[TestMethod]
		public void test_get_leaf_dir_name()
		{
			string path = DevGlobal.PATH_SOLUTION;
			Console.WriteLine(path);
			Console.WriteLine(DirOM.GetLeafDirectoryName(path));
		}

		[TestMethod]
		public void test_combine_path()
		{
			// There are bugs, try to avoid them not to prevent them, as you don't always consider comprehensive
			Console.WriteLine(Path.Combine("D:", "test"));  // It's an bug with result "D:test"
			Console.WriteLine(Path.Combine("D:", @"\test"));  // It's an bug bug with result "\test"
			Console.WriteLine(DirOM.CombinePath("d:", "test"));  // Fix bug, old result "d:test"
			Console.WriteLine(DirOM.CombinePath(@"d:\", @"\test"));
			Console.WriteLine(DirOM.CombinePath("d:", "test", "test3"));
			Console.WriteLine(DirOM.CombinePath(@"d:\", "test", "test3"));
			Console.WriteLine(DirOM.CombinePath(@"d:\", "test", "test3"));
		}

		[TestMethod]
		public void test_combine_uri()
		{
			Console.WriteLine(DirOM.CombineUrl("ftp://172.0.0.1", "test"));
			Console.WriteLine(DirOM.CombineUrl("ftp://172.0.0.1", @"test\test2"));
			Console.WriteLine(DirOM.CombineUrl("ftp://172.0.0.1", @"test\test2", "test3"));
			Console.WriteLine(DirOM.CombineUrl("ftp://172.0.0.1", @"test\test2", "test3", "hs.txt"));
		}

		[TestMethod]
		public void test_get_last_sub_path()
		{
			Console.WriteLine(DirOM.GetLastSubDirectory(@"C:\test\scn\office", 2));
		}

	}
}
